package com.jiyun.controller;

import com.jiyun.pojo.entity.Order;
import com.jiyun.pojo.vo.OrderVo;
import com.jiyun.service.FaDanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("fadan")
public class FaDanController {

    @Autowired
    private FaDanService faDanService;

    @GetMapping("findAllPutongOrder")
    public List<OrderVo> findAllPutongOrder(Integer userid){
        List<OrderVo> list= faDanService.findAllPutongOrder(userid);
        return list;
    }
    @RequestMapping("selectstatus")
    public List<OrderVo> selectstatus(Integer userid,Integer seid){
        if (seid==0){
            return faDanService.findAllPutongOrder(userid);
        }
        return faDanService.selectstatus(userid,seid);
    }

    //发布信息
    @RequestMapping("Fadan")
    public void Fandan(Order order){
        faDanService.Fandan(order);
    }
    //用户取消发单
    @RequestMapping("updatestatusidQuxiao")
    public void updatestatusidQuxiao(Integer oid){
        faDanService.updatestatusidQuxiao(oid);
    }
    //用户确认送达
    @RequestMapping("querenshou")
    public void querenshou(Integer oid,Double amout,Integer userid,Integer ptid){
        System.out.println(oid+"-"+amout+"-"+userid+"-"+ptid);
        faDanService.querenshou(oid,amout,userid,ptid);
    }
    //用户确认送达
    @RequestMapping("fukuan")
    public void fukuan(Integer oid,Double amout,Integer userid,Integer ptid){
        System.out.println(oid+"-"+amout+"-"+userid+"-"+ptid);
        faDanService.fukuan(oid,amout,userid,ptid);
    }
    //评价变为状态为待审核pingjia
    @RequestMapping("pingjia")
    public void pingjia(Integer oid,String estimate){
        System.out.println(oid+"-"+estimate);
        faDanService.pingjia(oid,estimate);
    }
    //重新提交订单
    @RequestMapping("findOrderBYid")
    public Order findOrderBYid(Integer oid){
        return faDanService.findOrderBYid(oid);
    }

}
